//
//  WMCameraViewController.m
//  Mink
//
//  Created by 周述坚 on 17/6/22.
//  Copyright © 2017年 周述坚. All rights reserved.
//

#import "WMCameraViewController.h"
#import "WMCameraView.h"
#import "WMBottomView.h"


@interface WMCameraViewController ()

// 若没有连接摄像头时的蓝色view
@property (nonatomic,strong)UIView *blueView;

// 底部视图
@property (nonatomic,strong)WMBottomView *bottomView;

// 摄像区域
@property (nonatomic,strong)WMCameraView *cameraView;

//



@end

@implementation WMCameraViewController{
    // 是否连接设备
    BOOL isConnection;

}

- (void)setupUI{
    
    // 设置颜色
    [self.view setBackgroundColor:[UIColor sj_colorWithHex:0xcc000000]];
    self.navigationController.navigationBar.barTintColor = [UIColor clearColor];
    [self.view addSubview:self.cameraView];
    [self.cameraView createPreviewController:self];
    isConnection = NO;
    self.bottomView.isConnection = isConnection;
    if (!isConnection) {
        [self.view addSubview:self.blueView];
    }
    [self.view addSubview:self.bottomView];
    
   
    
}

#pragma mark - 懒加载
- (UIView *)blueView{
    if (_blueView == nil) {
        UIView *blue = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT-64)];
        blue.backgroundColor = [UIColor grayColor];
        _blueView = blue;
    }
    return _blueView;
}

- (WMBottomView *)bottomView{
    if (_bottomView == nil) {
        WMBottomView *bottom = [[WMBottomView alloc] initWithFrame:CGRectMake(0, SCREENHEIGHT-166-64, SCREENWIDTH, 166)];
        bottom.backgroundColor = [UIColor sj_colorWithHex:0xcc000000];
        bottom.alpha = 0.6;
        _bottomView = bottom;
    }
    return _bottomView;
}

- (WMCameraView *)cameraView{
    if (_cameraView == nil) {
        WMCameraView *camera = [[WMCameraView alloc] initWithFrame:self.view.bounds];
        camera.backgroundColor = [UIColor whiteColor];
        _cameraView = camera;
    }
    return _cameraView;
}






@end
